<template>
  <div style="margin: 20px">
    <SalaryForm ref="salaryForm" v-loading="loading" :isDisabled="false"/>
    <AuditView :form-value="auditResult" :on-submit="save"></AuditView>
  </div>
</template>

<script setup>
import {onMounted, ref} from "vue";
import SalaryForm from './SalaryForm.vue'
import Salary from '@/api/Salary.js';
import AuditView from "@/components/flow/AuditView.vue";
import {useRouter} from "vue-router"

const router = useRouter()
const loading = ref(false);
const salaryForm = ref(null);
const auditResult = ref({"dealResult":200, "rejectReason":'', "salary":{}});


onMounted(() => {
});


const save = () => {
  auditResult.value.salary = salaryForm.value.getSalaryFormValue();
  loading.value = true
  Salary.makeSalary(auditResult.value)
      .then(res => {
        loading.value = false
        router.push({ name: 'home'});
      })
      .catch(error => {
        loading.value = false
      })
}
</script>

<style scoped>
</style>